package com.edu.exam.entity.examination.paper;

import com.edu.exam.enums.InvigilationAssignmentDetailStatus;
import com.edu.exam.enums.InvigilationConfirmationStatus;
import com.edu.exam.enums.InvigilatorRole;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

/**
 * 监考安排详情实体类
 *
 * <p>监考安排详情实体，记录监考安排中每个监考员的具体安排信息。
 * 包含分配角色、状态、时间等详细信息。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-09
 */
@Entity
@Table(name = "invigilation_assignment_detail",
       uniqueConstraints = @UniqueConstraint(columnNames = {"assignment_id", "invigilator_id"}))
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InvigilationAssignmentDetail {

    /**
     * 详情ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long detailId;

    /**
     * 安排ID
     */
    @Column(name = "assignment_id", nullable = false)
    private Long assignmentId;

    /**
     * 监考员ID
     */
    @Column(name = "invigilator_id", nullable = false)
    private Long invigilatorId;

    /**
     * 监考员姓名
     */
    @Column(name = "invigilator_name", length = 50, nullable = false)
    private String invigilatorName;

    /**
     * 监考员编号
     */
    @Column(name = "invigilator_code", length = 20, nullable = false)
    private String invigilatorCode;

    /**
     * 监考员角色
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "invigilator_role", length = 20, nullable = false)
    private InvigilatorRole invigilatorRole;

    /**
     * 分配状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "assignment_status", length = 20, nullable = false)
    private InvigilationAssignmentDetailStatus assignmentStatus;

    /**
     * 分配时间
     */
    @Column(name = "assigned_time", nullable = false)
    private LocalDateTime assignedTime;

    /**
     * 分配人ID
     */
    @Column(name = "assigned_by", length = 32, nullable = false)
    private String assignedBy;

    /**
     * 分配人姓名
     */
    @Column(name = "assigned_by_name", length = 50)
    private String assignedByName;

    /**
     * 确认时间
     */
    @Column(name = "confirmed_time")
    private LocalDateTime confirmedTime;

    /**
     * 确认状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "confirmation_status", length = 20)
    private InvigilationConfirmationStatus confirmationStatus;

    /**
     * 签到时间
     */
    @Column(name = "check_in_time")
    private LocalDateTime checkInTime;

    /**
     * 签退时间
     */
    @Column(name = "check_out_time")
    private LocalDateTime checkOutTime;

    /**
     * 实际监考时长（分钟）
     */
    @Column(name = "actual_duration_minutes")
    private Integer actualDurationMinutes;

    /**
     * 监考费用
     */
    @Column(name = "invigilation_fee")
    private Double invigilationFee;

    /**
     * 工作评价
     */
    @Column(name = "performance_rating", length = 20)
    private String performanceRating;

    /**
     * 工作评语
     */
    @Column(name = "performance_comment", length = 500)
    private String performanceComment;

    /**
     * 评价人ID
     */
    @Column(name = "evaluated_by", length = 32)
    private String evaluatedBy;

    /**
     * 评价时间
     */
    @Column(name = "evaluated_time")
    private LocalDateTime evaluatedTime;

    /**
     * 备注
     */
    @Column(name = "remarks", length = 500)
    private String remarks;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @LastModifiedDate
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 监考安排关联
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "assignment_id", insertable = false, updatable = false)
    private InvigilationAssignment assignment;

    /**
     * 监考员关联
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "invigilator_id", insertable = false, updatable = false)
    private Invigilator invigilator;




}